﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace LightWadf.Result
{
    public class XmlResult
    {
        private string xml;
        public string XmlString
        {
            get
            {
                return this.xml;
            }
        }

        public XmlResult(object obj)
        {
            if (obj != null)
            {
                XmlSerializer serializer = new XmlSerializer(obj.GetType());
                using (MemoryStream stream = new MemoryStream())
                {
                    serializer.Serialize(stream, obj);
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        this.xml = reader.ReadToEnd();
                    }
                }
            }
        }
    }
}
